/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.lcfgly.Form.Validation;

import com.lcfgly.CustomBean.LoginForm;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 *
 * @author lcfgly
 */
public class LoginValidation implements Validator{

    @Override
    public boolean supports(Class<?> clazz) {
        return LoginForm.class.equals(clazz);
    }

    @Override
    public void validate(Object target, Errors errors) {
        ValidationUtils.rejectIfEmpty(errors, "username",null, "用户名不能为空");
        ValidationUtils.rejectIfEmpty(errors, "password",null, "密码不能为空");
        ValidationUtils.rejectIfEmpty(errors, "vcode",null, "验证码不能为空");
    }
    
}
